package com.nondo.rdp.finance.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonValue;
import com.nondo.rdp.core.domain.base.BaseEntity;
import com.nondo.rdp.finance.config.DbConfig;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 文章DAO
 */
@Entity
@Table(name = DbConfig.DEFAULT_TABLE_PREFIX + "article")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Article extends BaseEntity {
    private Long id;    //自增ID
    private String title;   //标题
    private String body;    //内容
    private String type;    //文章类型，比如about=关于我们，protocol=用户协议，可以自定义，系统自带两篇文章
    private String remark; //备注

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @NotNull(message = "标题不能为空")
    @Length(min = 1, max = 32, message = "标题长度不能超过32个字符")
    @Column(name = "title", length = 32)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @NotNull(message = "内容不能为空")
    @Column(name = "body", columnDefinition = "text")
    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
